using Assets.Scripts.Manager;
using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GameView : MonoBehaviour
{
    [SerializeField] private Text _showTimeText;
    [SerializeField] private Text _bombCountText;

    private void OnEnable()
    {
        AddInputEvent();
    }
    private void OnDisable()
    {
        RemoveInputEvent();
    }

    private void Start()
    {
        UpdateTime();
    }
    private void Update()
    {
        UpdateTime();
    }

    private void UpdateTime()
    {
        _showTimeText.text = TimeManager.Instance.TimeLeft.ToString();
    }

    private void UpdateBombCount() 
    {

    }

    #region Input
    private void AddInputEvent()
    {
        InputManager.Instance.OnSelectClickEvent += OnSelectClicked;
        InputManager.Instance.OnStartClickEvent += OnStartClicked;
    }


    private void RemoveInputEvent()
    {
        InputManager.Instance.OnSelectClickEvent -= OnSelectClicked;
        InputManager.Instance.OnStartClickEvent -= OnStartClicked;
    }
    private bool _doing=true;
    private void OnStartClicked()
    {
        _doing = !_doing;
        if (_doing)
        {
            GameSystem.Instance.ChangeGameState(State.Pause);
        }
        else
        {
            GameSystem.Instance.ChangeGameState(State.Running);
        }
    }

    private void OnSelectClicked()
    {
        //GameManager.Instance.CurrentPlayer.Die(null);
        GameSystem.Instance.ChangeGameState(State.Failure);

    }
    #endregion
}
